package org.wmq.organizationmanagement.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.wmq.organizationmanagement.mapper.AdminMapper;
import org.wmq.organizationmanagement.model.po.Admin;
import org.wmq.organizationmanagement.service.AdminService;

@Service
@RequiredArgsConstructor
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
    @Override
    public Admin getByName(String name) {
        return this.lambdaQuery().eq(Admin::getName, name)
                .select(Admin::getId, Admin::getPassword, Admin::getAge,
                        Admin::getGender, Admin::getPhone)
                .one();
    }

    @Override
    public boolean nameIsExist(String name) {
        return this.lambdaQuery().eq(Admin::getName, name).count() == 0;
    }
}
